$(function() {
    let userId = getCookie("userId");
    let token = getCookie("token");
    // 注销登录
    $(".logout").on("click", function() {
        let options = {
            url: "http://127.0.0.1:8888/users/logout/" + userId,
            type: "get",

        }
        $.ajax(options)
            .done(function(res) {
                if (res.code === 1) {
                    console.log("1");
                    $(".think_login").css({ display: "block" }).siblings().css({ display: "none" });
                }
            })
    })

    // 用户信息
    let options = {
        url: "http://127.0.0.1:8888/users/info/" + userId,
        type: "get",
        headers: {
            authorization: token
        },
        dataType: "json"
    }
    $.ajax(options)
        .done(function(res) {
            if (res.code !== 0 && userId !== "undefined") {
                $(".think_login").css({ display: "none" }).siblings().css({ display: "block" })
                $(".ellipsis").html(res.info.nickname + ":" + res.info.username)
            }
        })



})